// import { Wrapper as OSS } from 'ali-oss'
import Api from '@/apis/app'
import store from '@/store'

// const ossConfig = {
//   region: 'oss-cn-hangzhou',
//   accessid: 'fklSF97boJxV9EzE',
//   accesskey: 'eXWoVbnNw1RJ2yMRq7fEWu2AgTI9Ng',
//   bucket: 'yfd-voice'
// }

export default {
  config: {},
  getClient () {
    return new Promise((resolve) => {
      Api.getOssConfig(store.state.app.id).then(data => {
        const client = new window.OSS.Wrapper({
          region: data.region,
          accessKeyId: data.accessid,
          accessKeySecret: data.accesskey,
          bucket: data.bucket
        })
        this.config = data
        resolve({ client, config: data })
      })
    })
  }
}
